﻿using System;
using System.Collections.Generic;
using Character;
using UnityEngine;
using Utility;

// Token: 0x02000147 RID: 327
public class Head : CharaShapeCustomBase
{
	// Token: 0x060007F2 RID: 2034 RVA: 0x0002F5E4 File Offset: 0x0002D7E4
	public Head(Human human, Transform parent) : base(human)
	{
		this.MouthReset = false;
		this.parent = parent;
		if (human.sex == SEX.FEMALE)
		{
			this.info = new ShapeHeadInfoFemale();
		}
		else if (human.sex == SEX.MALE)
		{
			this.info = new ShapeHeadInfoMale();
		}
	}

	// Token: 0x170000ED RID: 237
	// (get) Token: 0x060007F3 RID: 2035 RVA: 0x0002F64C File Offset: 0x0002D84C
	public Transform Parent
	{
		get
		{
			return this.parent;
		}
	}

	// Token: 0x170000EE RID: 238
	// (get) Token: 0x060007F4 RID: 2036 RVA: 0x0002F654 File Offset: 0x0002D854
	public Renderer Rend_eyebrow
	{
		get
		{
			return this.rend_eyebrow;
		}
	}

	// Token: 0x170000EF RID: 239
	// (get) Token: 0x060007F5 RID: 2037 RVA: 0x0002F65C File Offset: 0x0002D85C
	public Renderer Rend_eyelash
	{
		get
		{
			return this.rend_eyelash;
		}
	}

	// Token: 0x170000F0 RID: 240
	// (get) Token: 0x060007F6 RID: 2038 RVA: 0x0002F664 File Offset: 0x0002D864
	public Renderer Rend_eye_L
	{
		get
		{
			return this.rend_eye_L;
		}
	}

	// Token: 0x170000F1 RID: 241
	// (get) Token: 0x060007F7 RID: 2039 RVA: 0x0002F66C File Offset: 0x0002D86C
	public Renderer Rend_eye_R
	{
		get
		{
			return this.rend_eye_R;
		}
	}

	// Token: 0x170000F2 RID: 242
	// (get) Token: 0x060007F8 RID: 2040 RVA: 0x0002F674 File Offset: 0x0002D874
	public Renderer Rend_eyeHighlight_L
	{
		get
		{
			return this.rend_eyeHighlight_L;
		}
	}

	// Token: 0x170000F3 RID: 243
	// (get) Token: 0x060007F9 RID: 2041 RVA: 0x0002F67C File Offset: 0x0002D87C
	public Renderer Rend_eyeHighlight_R
	{
		get
		{
			return this.rend_eyeHighlight_R;
		}
	}

	// Token: 0x170000F4 RID: 244
	// (get) Token: 0x060007FA RID: 2042 RVA: 0x0002F684 File Offset: 0x0002D884
	public Renderer Rend_beard
	{
		get
		{
			return this.rend_beard;
		}
	}

	// Token: 0x170000F5 RID: 245
	// (get) Token: 0x060007FB RID: 2043 RVA: 0x0002F68C File Offset: 0x0002D88C
	public Renderer Rend_tongue
	{
		get
		{
			return this.rend_tongue;
		}
	}

	// Token: 0x170000F6 RID: 246
	// (get) Token: 0x060007FC RID: 2044 RVA: 0x0002F694 File Offset: 0x0002D894
	public Material CustomHighlightMat_Eye_L
	{
		get
		{
			return this.customHighlightMat_Eye_L;
		}
	}

	// Token: 0x170000F7 RID: 247
	// (get) Token: 0x060007FD RID: 2045 RVA: 0x0002F69C File Offset: 0x0002D89C
	public Material CustomHighlightMat_Eye_R
	{
		get
		{
			return this.customHighlightMat_Eye_R;
		}
	}

	// Token: 0x170000F8 RID: 248
	// (get) Token: 0x060007FE RID: 2046 RVA: 0x0002F6A4 File Offset: 0x0002D8A4
	public Material CustomHighlightMat_Eyebrow
	{
		get
		{
			return this.customHighlightMat_Eyebrow;
		}
	}

	// Token: 0x170000F9 RID: 249
	// (get) Token: 0x060007FF RID: 2047 RVA: 0x0002F6AC File Offset: 0x0002D8AC
	// (set) Token: 0x06000800 RID: 2048 RVA: 0x0002F6B4 File Offset: 0x0002D8B4
	public bool MouthReset { get; private set; }

	// Token: 0x06000801 RID: 2049 RVA: 0x0002F6C0 File Offset: 0x0002D8C0
	public void Load(HeadParameter param)
	{
		if (this.obj != null)
		{
			this.obj.transform.SetParent(null);
			UnityEngine.Object.Destroy(this.obj);
		}
		HeadData headData = null;
		if (this.human.sex == SEX.FEMALE)
		{
			headData = CustomDataManager.GetHead_Female(param.headID);
		}
		else if (this.human.sex == SEX.MALE)
		{
			headData = CustomDataManager.GetHead_Male(param.headID);
		}
		headData.isNew = false;
		this.obj = ResourceUtility.CreateInstance<GameObject>(headData.path);
		this.obj.transform.SetParent(this.parent, false);
		this.obj.transform.localScale = Vector3.one;
		this.obj.transform.localRotation = Quaternion.identity;
		this.obj.transform.localPosition = Vector3.zero;
		string b = (this.human.sex != SEX.FEMALE) ? Head.name_skin_Male : Head.name_skin_Female;
		string b2 = (this.human.sex != SEX.FEMALE) ? Head.name_eyebrow_Male : Head.name_eyebrow_Female;
		string b3 = (this.human.sex != SEX.FEMALE) ? Head.name_eye_L_Male : Head.name_eye_L_Female;
		string b4 = (this.human.sex != SEX.FEMALE) ? Head.name_eye_R_Male : Head.name_eye_R_Female;
		string b5 = (this.human.sex != SEX.FEMALE) ? Head.name_eyeHighlight_L_Male : Head.name_eyeHighlight_L_Female;
		string b6 = (this.human.sex != SEX.FEMALE) ? Head.name_eyeHighlight_R_Male : Head.name_eyeHighlight_R_Female;
		string b7 = (this.human.sex != SEX.FEMALE) ? Head.name_tongue_Male : Head.name_tongue_Female;
		string name_skinMaterial = (this.human.sex != SEX.FEMALE) ? Head.name_faceMaterial_Male : Head.name_faceMaterial_Female;
		this.rends_other.Clear();
		Renderer[] componentsInChildren = this.obj.GetComponentsInChildren<Renderer>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			if (componentsInChildren[i].name == b)
			{
				this.rend_skin = componentsInChildren[i];
			}
			else if (componentsInChildren[i].name == b2)
			{
				this.rend_eyebrow = componentsInChildren[i];
			}
			else if (componentsInChildren[i].name == b3)
			{
				this.rend_eye_L = componentsInChildren[i];
			}
			else if (componentsInChildren[i].name == b4)
			{
				this.rend_eye_R = componentsInChildren[i];
			}
			else if (componentsInChildren[i].name == b5)
			{
				this.rend_eyeHighlight_L = componentsInChildren[i];
			}
			else if (componentsInChildren[i].name == b6)
			{
				this.rend_eyeHighlight_R = componentsInChildren[i];
			}
			else if (componentsInChildren[i].name == b7)
			{
				this.rend_tongue = componentsInChildren[i];
			}
			else
			{
				this.rends_other.Add(componentsInChildren[i]);
			}
		}
		if (this.human.sex == SEX.FEMALE)
		{
			this.rend_eyelash = Transform_Utility.FindTransform(this.obj.transform, Head.name_eyelash_Female).GetComponent<Renderer>();
		}
		else if (this.human.sex == SEX.MALE)
		{
			this.rend_beard = Transform_Utility.FindTransform(this.obj.transform, Head.name_beard).GetComponent<Renderer>();
		}
		this.SetShowTongue(this.showTongue);
		this.anime = this.obj.GetComponentInChildren<Animator>();
		base.Setup_MaterialAndTexture(this.rend_skin, name_skinMaterial);
		if (this.human.sex == SEX.FEMALE)
		{
			this.info.InitShapeInfo(CustomDataManager.GetFaceShapes_Female(param.headID), CustomDataManager.FaceCategory_Female, this.obj.transform);
		}
		else if (this.human.sex == SEX.MALE)
		{
			this.info.InitShapeInfo(CustomDataManager.GetFaceShapes_Male(param.headID), CustomDataManager.FaceCategory_Male, this.obj.transform);
		}
		this.ShapeApply();
		this.ChangeEyebrow();
		this.ChangeEyelash();
		this.ChangeEye_LR();
		this.ChangeEyeHighlight();
		this.ChangeBeard();
		this.LoadSkin();
		this.UpdateCustomHighlightMaterial();
	}

	// Token: 0x06000802 RID: 2050 RVA: 0x0002FB2C File Offset: 0x0002DD2C
	public void SetupFaceMaterial()
	{
		string name_skinMaterial = (this.human.sex != SEX.FEMALE) ? Head.name_faceMaterial_Male : Head.name_faceMaterial_Female;
		base.Setup_Material(this.rend_skin, name_skinMaterial);
	}

	// Token: 0x06000803 RID: 2051 RVA: 0x0002FB68 File Offset: 0x0002DD68
	public void SetupFaceMaterialAndTexture()
	{
		string name_skinMaterial = (this.human.sex != SEX.FEMALE) ? Head.name_faceMaterial_Male : Head.name_faceMaterial_Female;
		base.Setup_MaterialAndTexture(this.rend_skin, name_skinMaterial);
	}

	// Token: 0x06000804 RID: 2052 RVA: 0x0002FBA4 File Offset: 0x0002DDA4
	public override void ShapeApply()
	{
		CustomParameter customParam = this.human.customParam;
		for (int i = 0; i < customParam.head.shapeVals.Length; i++)
		{
			this.info.ChangeValue(i, customParam.head.shapeVals[i]);
		}
		this.info.Update();
		base.IsShapeChange = false;
	}

	// Token: 0x06000805 RID: 2053 RVA: 0x0002FC08 File Offset: 0x0002DE08
	public override void SetShape(int category, float value)
	{
		this.human.customParam.head.shapeVals[category] = value;
		base.IsShapeChange = true;
	}

	// Token: 0x06000806 RID: 2054 RVA: 0x0002FC2C File Offset: 0x0002DE2C
	public override float GetShape(int category)
	{
		return this.human.customParam.head.shapeVals[category];
	}

	// Token: 0x06000807 RID: 2055 RVA: 0x0002FC48 File Offset: 0x0002DE48
	public void ChangeSkinMaterial()
	{
		AssetBundleController assetBundleController = new AssetBundleController();
		HeadParameter head = this.human.customParam.head;
		PrefabData prefabData = null;
		if (this.human.sex == SEX.FEMALE)
		{
			prefabData = CustomDataManager.GetFaceSkin_Female(head.faceTexID);
		}
		else if (this.human.sex == SEX.MALE)
		{
			prefabData = CustomDataManager.GetFaceSkin_Male(head.faceTexID);
		}
		prefabData.isNew = false;
		assetBundleController.OpenFromFile(prefabData.assetbundleDir, prefabData.assetbundleName);
		Material mat = assetBundleController.LoadAsset<Material>(prefabData.prefab);
		this.skinMaterial.CopyPropertiesFromMaterial(mat);
		assetBundleController.Close(false);
		this.skinBaseTex = this.skinMaterial.mainTexture;
		this.skinNormalTex = this.skinMaterial.GetTexture("_BumpMap");
		this.RendSkinTexture();
		this.RendNormalTexture();
		this.human.UpdateSkinMaterial();
		Resources.UnloadUnusedAssets();
	}

	// Token: 0x06000808 RID: 2056 RVA: 0x0002FD2C File Offset: 0x0002DF2C
	public void LoadSkin()
	{
		this.ChangeSkinMaterial();
		this.ChangeTattoo();
		this.ChangeEyeShadow();
		this.ChangeCheek();
		this.ChangeLip();
		this.ChangeMole();
		this.RendSkinTexture();
	}

	// Token: 0x06000809 RID: 2057 RVA: 0x0002FD58 File Offset: 0x0002DF58
	public void ChangeEyebrow()
	{
		HeadParameter head = this.human.customParam.head;
		PrefabData prefabData = null;
		if (this.human.sex == SEX.FEMALE)
		{
			prefabData = CustomDataManager.GetEyebrow_Female(head.eyeBrowID);
		}
		else if (this.human.sex == SEX.MALE)
		{
			prefabData = CustomDataManager.GetEyebrow_Male(head.eyeBrowID);
		}
		prefabData.isNew = false;
		this.rend_eyebrow.material = AssetBundleLoader.LoadAsset<Material>(prefabData.assetbundleDir, prefabData.assetbundleName, prefabData.prefab);
		this.ChangeEyebrowColor();
	}

	// Token: 0x0600080A RID: 2058 RVA: 0x0002FDE8 File Offset: 0x0002DFE8
	public void ChangeEyebrowColor()
	{
		HeadParameter head = this.human.customParam.head;
		head.eyeBrowColor.SetToMaterial(this.rend_eyebrow.material);
	}

	// Token: 0x0600080B RID: 2059 RVA: 0x0002FE1C File Offset: 0x0002E01C
	public void ChangeEyelash()
	{
		if (this.human.sex != SEX.FEMALE)
		{
			return;
		}
		HeadParameter head = this.human.customParam.head;
		PrefabData eyelash = CustomDataManager.GetEyelash(head.eyeLashID);
		eyelash.isNew = false;
		this.rend_eyelash.material = AssetBundleLoader.LoadAsset<Material>(eyelash.assetbundleDir, eyelash.assetbundleName, eyelash.prefab);
		this.ChangeEyelashColor();
	}

	// Token: 0x0600080C RID: 2060 RVA: 0x0002FE88 File Offset: 0x0002E088
	public void ChangeEyelashColor()
	{
		if (this.human.sex != SEX.FEMALE)
		{
			return;
		}
		HeadParameter head = this.human.customParam.head;
		head.eyeLashColor.SetToMaterial(this.rend_eyelash.material);
	}

	// Token: 0x0600080D RID: 2061 RVA: 0x0002FED0 File Offset: 0x0002E0D0
	public void ChangeEye_L()
	{
		HeadParameter head = this.human.customParam.head;
		PrefabData prefabData = null;
		if (this.human.sex == SEX.FEMALE)
		{
			prefabData = CustomDataManager.GetEye_Female(head.eyeID_L);
		}
		else if (this.human.sex == SEX.MALE)
		{
			prefabData = CustomDataManager.GetEye_Male(head.eyeID_L);
		}
		prefabData.isNew = false;
		this.rend_eye_L.material = AssetBundleLoader.LoadAsset<Material>(prefabData.assetbundleDir, prefabData.assetbundleName, prefabData.prefab);
		this.ChangeEyeColor_L();
	}

	// Token: 0x0600080E RID: 2062 RVA: 0x0002FF60 File Offset: 0x0002E160
	public void ChangeEye_R()
	{
		HeadParameter head = this.human.customParam.head;
		PrefabData prefabData = null;
		if (this.human.sex == SEX.FEMALE)
		{
			prefabData = CustomDataManager.GetEye_Female(head.eyeID_R);
		}
		else if (this.human.sex == SEX.MALE)
		{
			prefabData = CustomDataManager.GetEye_Male(head.eyeID_R);
		}
		prefabData.isNew = false;
		this.rend_eye_R.material = AssetBundleLoader.LoadAsset<Material>(prefabData.assetbundleDir, prefabData.assetbundleName, prefabData.prefab);
		this.ChangeEyeColor_R();
	}

	// Token: 0x0600080F RID: 2063 RVA: 0x0002FFF0 File Offset: 0x0002E1F0
	public void ChangeEye_LR()
	{
		this.ChangeEye_L();
		this.ChangeEye_R();
	}

	// Token: 0x06000810 RID: 2064 RVA: 0x00030000 File Offset: 0x0002E200
	public void ChangeEyeColor_L()
	{
		HeadParameter head = this.human.customParam.head;
		this.rend_eye_L.material.SetColor("_ScleraColor", head.eyeScleraColorL);
		this.rend_eye_L.material.SetColor("_IrisColor", head.eyeIrisColorL);
		this.rend_eye_L.material.SetFloat("_IrisPupilSize", head.eyePupilDilationL);
		float value = this.CalcIrisScatterIntensity(head.eyeEmissiveL);
		float value2 = this.CalcIrisScatterPower(head.eyeEmissiveL);
		this.rend_eye_L.material.SetFloat("_IrisScatterIntensity", value);
		this.rend_eye_L.material.SetFloat("_IrisScatterPower", value2);
	}

	// Token: 0x06000811 RID: 2065 RVA: 0x000300B8 File Offset: 0x0002E2B8
	public void ChangeEyeColor_R()
	{
		HeadParameter head = this.human.customParam.head;
		this.rend_eye_R.material.SetColor("_ScleraColor", head.eyeScleraColorR);
		this.rend_eye_R.material.SetColor("_IrisColor", head.eyeIrisColorR);
		this.rend_eye_R.material.SetFloat("_IrisPupilSize", head.eyePupilDilationR);
		float value = this.CalcIrisScatterIntensity(head.eyeEmissiveR);
		float value2 = this.CalcIrisScatterPower(head.eyeEmissiveR);
		this.rend_eye_R.material.SetFloat("_IrisScatterIntensity", value);
		this.rend_eye_R.material.SetFloat("_IrisScatterPower", value2);
	}

	// Token: 0x06000812 RID: 2066 RVA: 0x00030170 File Offset: 0x0002E370
	private float CalcIrisScatterIntensity(float emissive)
	{
		if (emissive < 0.5f)
		{
			return Mathf.Lerp(0f, 5.5f, emissive * 2f);
		}
		return Mathf.Lerp(5.5f, 20f, (emissive - 0.5f) * 2f);
	}

	// Token: 0x06000813 RID: 2067 RVA: 0x000301B0 File Offset: 0x0002E3B0
	private float CalcIrisScatterPower(float emissive)
	{
		if (emissive < 0.5f)
		{
			return Mathf.Lerp(8f, 4.56f, emissive * 2f);
		}
		return Mathf.Lerp(4.56f, 1.5f, (emissive - 0.5f) * 2f);
	}

	// Token: 0x06000814 RID: 2068 RVA: 0x000301F0 File Offset: 0x0002E3F0
	public void ChangeEyeColor_LR()
	{
		this.ChangeEyeColor_L();
		this.ChangeEyeColor_R();
	}

	// Token: 0x06000815 RID: 2069 RVA: 0x00030200 File Offset: 0x0002E400
	public void ChangeEyeHighlight()
	{
		if (this.human.sex == SEX.FEMALE)
		{
			HeadParameter head = this.human.customParam.head;
			PrefabData eyeHighlight = CustomDataManager.GetEyeHighlight(head.eyeHighlightTexID);
			eyeHighlight.isNew = false;
			Material material = AssetBundleLoader.LoadAsset<Material>(eyeHighlight.assetbundleDir, eyeHighlight.assetbundleName, eyeHighlight.prefab);
			this.rend_eyeHighlight_L.material = material;
			this.rend_eyeHighlight_R.material = material;
		}
		this.ChangeEyeHighlightColor();
	}

	// Token: 0x06000816 RID: 2070 RVA: 0x00030278 File Offset: 0x0002E478
	public void ChangeEyeHighlightColor()
	{
		HeadParameter head = this.human.customParam.head;
		head.eyeHighlightColor.SetToMaterial(this.rend_eyeHighlight_L.material);
		head.eyeHighlightColor.SetToMaterial(this.rend_eyeHighlight_R.material);
	}

	// Token: 0x06000817 RID: 2071 RVA: 0x000302C4 File Offset: 0x0002E4C4
	public bool IsGlossEyeHighlight()
	{
		return ColorParameter_EyeHighlight.CheckGloss(this.rend_eyeHighlight_L.material);
	}

	// Token: 0x06000818 RID: 2072 RVA: 0x000302D8 File Offset: 0x0002E4D8
	public void ChangeBeard()
	{
		if (this.human.sex != SEX.MALE)
		{
			return;
		}
		HeadParameter head = this.human.customParam.head;
		PrefabData beard = CustomDataManager.GetBeard(head.beardID);
		beard.isNew = false;
		Material material = null;
		if (beard.prefab != "-")
		{
			material = AssetBundleLoader.LoadAsset<Material>(beard.assetbundleDir, beard.assetbundleName, beard.prefab);
			if (material != null)
			{
				this.rend_beard.material = material;
			}
		}
		this.rend_beard.gameObject.SetActive(material != null);
		this.ChangeBeardColor();
	}

	// Token: 0x06000819 RID: 2073 RVA: 0x00030380 File Offset: 0x0002E580
	public void ChangeBeardColor()
	{
		if (this.human.sex != SEX.MALE)
		{
			return;
		}
		HeadParameter head = this.human.customParam.head;
		this.rend_beard.material.color = head.beardColor;
	}

	// Token: 0x0600081A RID: 2074 RVA: 0x000303C8 File Offset: 0x0002E5C8
	public void RendSkinTexture()
	{
		if (this.human.sex == SEX.FEMALE)
		{
			this.RendSkinTexture_Female();
		}
		else if (this.human.sex == SEX.MALE)
		{
			this.RendSkinTexture_Male();
		}
	}

	// Token: 0x0600081B RID: 2075 RVA: 0x000303FC File Offset: 0x0002E5FC
	public void RendSkinTexture_Female()
	{
		HeadParameter head = this.human.customParam.head;
		CombineTextureData faceTattoo_Female = CustomDataManager.GetFaceTattoo_Female(head.tattooID);
		CombineTextureData eyeShadow = CustomDataManager.GetEyeShadow(head.eyeshadowTexID);
		CombineTextureData cheek = CustomDataManager.GetCheek(head.cheekTexID);
		CombineTextureData lip = CustomDataManager.GetLip(head.lipTexID);
		CombineTextureData mole = CustomDataManager.GetMole(head.moleTexID);
		Color white = Color.white;
		Color tattooColor = head.tattooColor;
		Color eyeshadowColor = head.eyeshadowColor;
		Color cheekColor = head.cheekColor;
		Color lipColor = head.lipColor;
		Color moleColor = head.moleColor;
		Material material = new Material(CustomDataManager.skinBlendShader_Face);
		bool sRGBWrite = GL.sRGBWrite;
		GL.sRGBWrite = true;
		Graphics.SetRenderTarget(this.skinTex);
		GL.Clear(false, true, Color.black);
		Graphics.SetRenderTarget(null);
		if (this.tattooTex == null)
		{
			tattooColor.a = 0f;
		}
		if (this.eyeshadowTex == null)
		{
			eyeshadowColor.a = 0f;
		}
		if (this.cheekTex == null)
		{
			cheekColor.a = 0f;
		}
		if (this.lipTex == null)
		{
			lipColor.a = 0f;
		}
		if (this.moleTex == null)
		{
			moleColor.a = 0f;
		}
		material.SetTexture("_BaseTex", this.skinBaseTex);
		material.SetFloat("_OffsetH", this.human.customParam.body.skinColor.offset_h);
		material.SetFloat("_OffsetS", this.human.customParam.body.skinColor.offset_s);
		material.SetFloat("_OffsetV", this.human.customParam.body.skinColor.offset_v);
		material.SetTexture("_CheekTex", this.cheekTex);
		if (this.cheekTex != null)
		{
			base.SetTattooOffsetAndTiling(material, "_CheekTex", 1024, 1024, this.cheekTex.width, this.cheekTex.height, cheek.pos.x, cheek.pos.y);
		}
		material.SetColor("_CheekColor", cheekColor);
		material.SetTexture("_EyeShadowTex", this.eyeshadowTex);
		if (this.eyeshadowTex != null)
		{
			base.SetTattooOffsetAndTiling(material, "_EyeShadowTex", 1024, 1024, this.eyeshadowTex.width, this.eyeshadowTex.height, eyeShadow.pos.x, eyeShadow.pos.y);
		}
		material.SetColor("_EyeShadowColor", eyeshadowColor);
		material.SetTexture("_LipTex", this.lipTex);
		if (this.lipTex != null)
		{
			base.SetTattooOffsetAndTiling(material, "_LipTex", 1024, 1024, this.lipTex.width, this.lipTex.height, lip.pos.x, lip.pos.y);
		}
		material.SetColor("_LipColor", lipColor);
		material.SetTexture("_MoleTex", this.moleTex);
		if (this.moleTex != null)
		{
			base.SetTattooOffsetAndTiling(material, "_MoleTex", 1024, 1024, this.moleTex.width, this.moleTex.height, mole.pos.x, mole.pos.y);
		}
		material.SetColor("_MoleColor", moleColor);
		material.SetTexture("_TattooTex", this.tattooTex);
		if (this.tattooTex != null)
		{
			base.SetTattooOffsetAndTiling(material, "_TattooTex", 1024, 1024, this.tattooTex.width, this.tattooTex.height, faceTattoo_Female.pos.x, faceTattoo_Female.pos.y);
		}
		material.SetColor("_TattooColor", tattooColor);
		Graphics.Blit(this.skinBaseTex, this.skinTex, material, 0);
		GL.sRGBWrite = sRGBWrite;
		this.skinMaterial.mainTexture = this.skinTex;
		if (faceTattoo_Female != null)
		{
			faceTattoo_Female.isNew = false;
		}
		if (eyeShadow != null)
		{
			eyeShadow.isNew = false;
		}
		if (cheek != null)
		{
			cheek.isNew = false;
		}
		if (lip != null)
		{
			lip.isNew = false;
		}
		if (mole != null)
		{
			mole.isNew = false;
		}
		UnityEngine.Object.Destroy(material);
	}

	// Token: 0x0600081C RID: 2076 RVA: 0x00030894 File Offset: 0x0002EA94
	public void RendSkinTexture_Male()
	{
		HeadParameter head = this.human.customParam.head;
		CombineTextureData faceTattoo_Male = CustomDataManager.GetFaceTattoo_Male(head.tattooID);
		Texture2D texture2D = (faceTattoo_Male != null) ? AssetBundleLoader.LoadAsset<Texture2D>(faceTattoo_Male.assetbundleDir, faceTattoo_Male.assetbundleName, faceTattoo_Male.textureName) : null;
		Color tattooColor = head.tattooColor;
		Material material = new Material(CustomDataManager.skinBlendShader_Male);
		bool sRGBWrite = GL.sRGBWrite;
		GL.sRGBWrite = true;
		Graphics.SetRenderTarget(this.skinTex);
		GL.Clear(false, true, Color.black);
		Graphics.SetRenderTarget(null);
		if (texture2D == null)
		{
			tattooColor.a = 0f;
		}
		material.SetTexture("_BaseTex", this.skinBaseTex);
		material.SetFloat("_OffsetH", this.human.customParam.body.skinColor.offset_h);
		material.SetFloat("_OffsetS", this.human.customParam.body.skinColor.offset_s);
		material.SetFloat("_OffsetV", this.human.customParam.body.skinColor.offset_v);
		material.SetTexture("_TattooTex", texture2D);
		if (texture2D != null)
		{
			base.SetTattooOffsetAndTiling(material, "_TattooTex", 1024, 1024, texture2D.width, texture2D.height, faceTattoo_Male.pos.x, faceTattoo_Male.pos.y);
		}
		material.SetColor("_TattooColor", tattooColor);
		Graphics.Blit(this.skinBaseTex, this.skinTex, material, 0);
		GL.sRGBWrite = sRGBWrite;
		this.skinMaterial.mainTexture = this.skinTex;
		if (faceTattoo_Male != null)
		{
			faceTattoo_Male.isNew = false;
		}
		UnityEngine.Object.Destroy(material);
	}

	// Token: 0x0600081D RID: 2077 RVA: 0x00030A5C File Offset: 0x0002EC5C
	public void RendNormalTexture()
	{
		HeadParameter head = this.human.customParam.head;
		Material material = new Material(CustomDataManager.normalAddShader_2);
		bool sRGBWrite = GL.sRGBWrite;
		GL.sRGBWrite = true;
		Graphics.SetRenderTarget(this.normalTex);
		GL.Clear(false, true, Color.white);
		Graphics.SetRenderTarget(null);
		PrefabData prefabData = (this.human.sex != SEX.FEMALE) ? CustomDataManager.GetFaceDetail_Male(head.detailID) : CustomDataManager.GetFaceDetail_Female(head.detailID);
		Texture2D texture2D = (prefabData != null) ? AssetBundleLoader.LoadAsset<Texture2D>(prefabData.assetbundleDir, prefabData.assetbundleName, prefabData.prefab) : null;
		if (texture2D != null)
		{
			material.SetTexture("_BlendTexA", this.skinNormalTex);
			material.SetTexture("_BlendTexB", texture2D);
			material.SetFloat("_Rate", head.detailWeight);
			Graphics.Blit(this.skinNormalTex, this.normalTex, material, 0);
			this.skinMaterial.SetTexture("_BumpMap", this.normalTex);
		}
		else
		{
			this.skinMaterial.SetTexture("_BumpMap", this.skinNormalTex);
		}
		GL.sRGBWrite = sRGBWrite;
		UnityEngine.Object.Destroy(material);
		if (prefabData != null)
		{
			prefabData.isNew = false;
		}
	}

	// Token: 0x0600081E RID: 2078 RVA: 0x00030B98 File Offset: 0x0002ED98
	public override void CreateCustomHighlightMaterial()
	{
		base.CreateCustomHighlightMaterial(ref this.customHighlightMat_Skin, this.rend_skin);
		base.CreateCustomHighlightMaterial(ref this.customHighlightMat_Eye_L, this.rend_eye_L);
		base.CreateCustomHighlightMaterial(ref this.customHighlightMat_Eye_R, this.rend_eye_R);
		base.CreateCustomHighlightMaterial(ref this.customHighlightMat_Eyebrow, this.rend_eyebrow);
	}

	// Token: 0x0600081F RID: 2079 RVA: 0x00030BF0 File Offset: 0x0002EDF0
	public override void DeleteCustomHighlightMaterial()
	{
		base.DeleteCustomHighlightMaterial(ref this.customHighlightMat_Skin, this.rend_skin);
		base.DeleteCustomHighlightMaterial(ref this.customHighlightMat_Eye_L, this.rend_eye_L);
		base.DeleteCustomHighlightMaterial(ref this.customHighlightMat_Eye_R, this.rend_eye_R);
		base.DeleteCustomHighlightMaterial(ref this.customHighlightMat_Eyebrow, this.rend_eyebrow);
	}

	// Token: 0x06000820 RID: 2080 RVA: 0x00030C48 File Offset: 0x0002EE48
	public void ResetMouth(bool reset)
	{
		this.MouthReset = reset;
		if (this.human.sex == SEX.FEMALE)
		{
			foreach (int num in new int[]
			{
				3,
				4,
				5,
				6,
				7,
				8,
				9,
				10,
				11,
				12,
				13,
				14,
				15,
				16,
				17,
				18,
				55,
				56,
				57,
				58,
				59,
				60,
				61
			})
			{
				float value = (!reset) ? this.human.customParam.head.shapeVals[num] : 0.5f;
				this.info.ChangeValue(num, value);
			}
			this.info.Update();
		}
		else
		{
			foreach (int num2 in new int[]
			{
				3,
				4,
				5,
				6,
				7,
				8,
				9,
				10,
				11,
				12,
				13,
				14,
				55,
				56,
				57,
				58,
				59,
				60,
				61
			})
			{
				float value2 = (!reset) ? this.human.customParam.head.shapeVals[num2] : 0.5f;
				this.info.ChangeValue(num2, value2);
			}
			this.info.Update();
		}
	}

	// Token: 0x06000821 RID: 2081 RVA: 0x00030D58 File Offset: 0x0002EF58
	public void SetShowTongue(bool show)
	{
		this.showTongue = show;
		if (this.rend_tongue != null)
		{
			this.rend_tongue.enabled = show;
		}
	}

	// Token: 0x06000822 RID: 2082 RVA: 0x00030D80 File Offset: 0x0002EF80
	public void ChangeShow(bool show)
	{
		this.rend_skin.enabled = show;
		this.rend_eyebrow.enabled = show;
		this.rend_eye_L.enabled = show;
		this.rend_eye_R.enabled = show;
		this.rend_eyeHighlight_L.enabled = show;
		this.rend_eyeHighlight_R.enabled = show;
		if (this.rend_eyelash != null)
		{
			this.rend_eyelash.enabled = show;
		}
		if (this.rend_beard != null)
		{
			this.rend_beard.enabled = show;
		}
		for (int i = 0; i < this.rends_other.Count; i++)
		{
			this.rends_other[i].enabled = show;
		}
	}

	// Token: 0x06000823 RID: 2083 RVA: 0x00030E40 File Offset: 0x0002F040
	public void ChangeTattoo()
	{
		int tattooID = this.human.customParam.head.tattooID;
		CombineTextureData combineTextureData = (this.human.sex != SEX.FEMALE) ? CustomDataManager.GetFaceTattoo_Male(tattooID) : CustomDataManager.GetFaceTattoo_Female(tattooID);
		this.tattooTex = ((combineTextureData != null) ? AssetBundleLoader.LoadAsset<Texture2D>(combineTextureData.assetbundleDir, combineTextureData.assetbundleName, combineTextureData.textureName) : null);
	}

	// Token: 0x06000824 RID: 2084 RVA: 0x00030EB0 File Offset: 0x0002F0B0
	public void ChangeEyeShadow()
	{
		CombineTextureData eyeShadow = CustomDataManager.GetEyeShadow(this.human.customParam.head.eyeshadowTexID);
		this.eyeshadowTex = ((eyeShadow != null) ? AssetBundleLoader.LoadAsset<Texture2D>(eyeShadow.assetbundleDir, eyeShadow.assetbundleName, eyeShadow.textureName) : null);
	}

	// Token: 0x06000825 RID: 2085 RVA: 0x00030F04 File Offset: 0x0002F104
	public void ChangeCheek()
	{
		CombineTextureData cheek = CustomDataManager.GetCheek(this.human.customParam.head.cheekTexID);
		this.cheekTex = ((cheek != null) ? AssetBundleLoader.LoadAsset<Texture2D>(cheek.assetbundleDir, cheek.assetbundleName, cheek.textureName) : null);
	}

	// Token: 0x06000826 RID: 2086 RVA: 0x00030F58 File Offset: 0x0002F158
	public void ChangeLip()
	{
		CombineTextureData lip = CustomDataManager.GetLip(this.human.customParam.head.lipTexID);
		this.lipTex = ((lip != null) ? AssetBundleLoader.LoadAsset<Texture2D>(lip.assetbundleDir, lip.assetbundleName, lip.textureName) : null);
	}

	// Token: 0x06000827 RID: 2087 RVA: 0x00030FAC File Offset: 0x0002F1AC
	public void ChangeMole()
	{
		CombineTextureData mole = CustomDataManager.GetMole(this.human.customParam.head.moleTexID);
		this.moleTex = ((mole != null) ? AssetBundleLoader.LoadAsset<Texture2D>(mole.assetbundleDir, mole.assetbundleName, mole.textureName) : null);
	}

	// Token: 0x040007BF RID: 1983
	protected Transform parent;

	// Token: 0x040007C0 RID: 1984
	protected Renderer rend_eyebrow;

	// Token: 0x040007C1 RID: 1985
	protected Renderer rend_eyelash;

	// Token: 0x040007C2 RID: 1986
	protected Renderer rend_eye_L;

	// Token: 0x040007C3 RID: 1987
	protected Renderer rend_eye_R;

	// Token: 0x040007C4 RID: 1988
	protected Renderer rend_eyeHighlight_L;

	// Token: 0x040007C5 RID: 1989
	protected Renderer rend_eyeHighlight_R;

	// Token: 0x040007C6 RID: 1990
	protected Renderer rend_beard;

	// Token: 0x040007C7 RID: 1991
	protected Renderer rend_tongue;

	// Token: 0x040007C8 RID: 1992
	protected List<Renderer> rends_other = new List<Renderer>();

	// Token: 0x040007C9 RID: 1993
	private static readonly string name_skin_Female = "cf_O_head";

	// Token: 0x040007CA RID: 1994
	private static readonly string name_eyebrow_Female = "cf_O_mayuge";

	// Token: 0x040007CB RID: 1995
	private static readonly string name_eyelash_Female = "cf_O_matuge";

	// Token: 0x040007CC RID: 1996
	private static readonly string name_eye_L_Female = "cf_O_eyewhite_L";

	// Token: 0x040007CD RID: 1997
	private static readonly string name_eye_R_Female = "cf_O_eyewhite_R";

	// Token: 0x040007CE RID: 1998
	private static readonly string name_eyeHighlight_L_Female = "cf_O_eyehikari_L";

	// Token: 0x040007CF RID: 1999
	private static readonly string name_eyeHighlight_R_Female = "cf_O_eyehikari_R";

	// Token: 0x040007D0 RID: 2000
	private static readonly string name_faceMaterial_Female = "cf_m_face";

	// Token: 0x040007D1 RID: 2001
	private static readonly string name_tongue_Female = "cf_O_sita";

	// Token: 0x040007D2 RID: 2002
	private static readonly string name_skin_Male = "cm_O_head";

	// Token: 0x040007D3 RID: 2003
	private static readonly string name_eyebrow_Male = "cm_O_mayuge";

	// Token: 0x040007D4 RID: 2004
	private static readonly string name_eye_L_Male = "cm_O_eye_L";

	// Token: 0x040007D5 RID: 2005
	private static readonly string name_eye_R_Male = "cm_O_eye_R";

	// Token: 0x040007D6 RID: 2006
	private static readonly string name_eyeHighlight_L_Male = "cm_O_eyeHi_L";

	// Token: 0x040007D7 RID: 2007
	private static readonly string name_eyeHighlight_R_Male = "cm_O_eyeHi_R";

	// Token: 0x040007D8 RID: 2008
	private static readonly string name_tongue_Male = "cm_O_sita";

	// Token: 0x040007D9 RID: 2009
	private static readonly string name_faceMaterial_Male = "cm_M_head";

	// Token: 0x040007DA RID: 2010
	private static readonly string name_beard = "O_hige00";

	// Token: 0x040007DB RID: 2011
	protected Material customHighlightMat_Eye_L;

	// Token: 0x040007DC RID: 2012
	protected Material customHighlightMat_Eye_R;

	// Token: 0x040007DD RID: 2013
	protected Material customHighlightMat_Eyebrow;

	// Token: 0x040007DE RID: 2014
	protected bool showTongue = true;

	// Token: 0x040007DF RID: 2015
	private Texture2D tattooTex;

	// Token: 0x040007E0 RID: 2016
	private Texture2D eyeshadowTex;

	// Token: 0x040007E1 RID: 2017
	private Texture2D cheekTex;

	// Token: 0x040007E2 RID: 2018
	private Texture2D lipTex;

	// Token: 0x040007E3 RID: 2019
	private Texture2D moleTex;
}
